package com.cskaoyan.market.service;

import com.cskaoyan.market.bo.FeedBackBo;
import com.cskaoyan.market.db.domain.MarketFeedback;
import com.cskaoyan.market.db.domain.MarketFeedbackExample;
import com.cskaoyan.market.db.domain.MarketUser;
import com.cskaoyan.market.db.mapper.MarketFeedbackMapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/20 22:16
 */
@Service
public class WxFeedBackServiceImpl implements  WxFeedBackService{
    @Autowired
    MarketFeedbackMapper marketFeedbackMapper;
    @Override
    public Integer feedback(FeedBackBo feedBackBo) {
        MarketFeedbackExample marketFeedbackExample=new MarketFeedbackExample();
        MarketFeedback marketFeedback=new MarketFeedback();
        marketFeedback.setMobile(feedBackBo.getMobile());
        marketFeedback.setFeedType(feedBackBo.getFeedType());
        marketFeedback.setContent(feedBackBo.getContent());
        marketFeedback.setHasPicture(feedBackBo.getHasPicture());
        marketFeedback.setPicUrls(feedBackBo.getPicUrls());
        Session session = SecurityUtils.getSubject().getSession();
        MarketUser user = (MarketUser) session.getAttribute("user");
        if(user!=null) {
            marketFeedback.setUserId(user.getId());
            marketFeedback.setUsername(user.getUsername());
        }
        else{
            return -1;
        }

        int res=marketFeedbackMapper.insertSelective(marketFeedback);
        return res;


    }
}
